package com.afkt.project.ui.slice;


import com.afkt.project.base.app.BaseActivity;
import com.ohos.afkt.ResourceTable;
import com.dev.utils.app.ResourceUtils;
import com.dev.widget.ui.SignView;
import ohos.aafwk.content.Intent;
import ohos.agp.colors.RgbColor;
import ohos.agp.components.*;
import ohos.agp.components.element.ShapeElement;
import ohos.agp.render.Paint;
import ohos.agp.utils.Color;

public class SignActivity extends BaseActivity {


    private DirectionalLayout bar_Layout;
    private DirectionalLayout bar;
    private Image select_retuen;

    @Override
    protected int baseLayoutId() {
        return ResourceTable.Layout_Layout_activity_sign;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initListener() {
        select_retuen.setClickedListener(component -> {
            // LogUtils.error(TAG, "return 点击");
            onBackPressed();
        });
    }

    @Override
    protected void onBackground() {
        super.onBackground();
        bar_Layout.removeAllComponents();
    }

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);

        bar_Layout = (DirectionalLayout) findComponentById(ResourceTable.Id_base_view_barLayout);
        bar = (DirectionalLayout) LayoutScatter.getInstance(this).parse(ResourceTable.Layout_sheet_dialog_bar, null, false);
        Text text = (Text) bar.findComponentById(ResourceTable.Id_titleText);
        select_retuen = (Image) bar.findComponentById(ResourceTable.Id_sheet_dialog_return);
        text.setText("签名 View");
        bar_Layout.addComponent(bar);

        SignView signView = new SignView(getContext());
        signView.setLayoutConfig(new DirectionalLayout.LayoutConfig(DirectionalLayout.LayoutConfig.MATCH_PARENT,
                DirectionalLayout.LayoutConfig.MATCH_PARENT));

        // 设置画笔
        Paint paint = new Paint();
        paint.setAntiAlias(true);
        paint.setStyle(Paint.Style.STROKE_STYLE);
        paint.setStrokeWidth(30f);
        paint.setColor(Color.BLACK);
        signView.setPaint(paint);


        ShapeElement shapeElement = new ShapeElement();
        shapeElement.setRgbColor(new RgbColor(0, 0, 0));

        signView.setBackground(ResourceUtils.getDrawable(ResourceTable.Media_icon));
/*        ComponentContainer rootView = (ComponentContainer) LayoutScatter.getInstance(getContext()).
                parse(ResourceTable.Layout_Layout_activity_sign, null, false);
        rootView.addComponent(signView, new DirectionalLayout.LayoutConfig(DirectionalLayout.LayoutConfig.MATCH_PARENT,
                DirectionalLayout.LayoutConfig.MATCH_PARENT));*/
    }

}
